package fr.cdj.thebox.shared;

import java.util.Arrays;
import java.util.List;

public enum FileType {

	ARCHIVE("rar", "zip"),
	AUDIO("mp3", "flac"),
	IMAGE("bmp", "gif", "jpg", "png"),
	OTHER,
	TEXT("doc", "odt", "txt"),
	VIDEO("avi", "mkv", "mp4");

	private List<String> extensions;

	private FileType(String... extensions) {
		this.extensions = Arrays.asList(extensions);
	}

	private List<String> getExtensions() {
		return extensions;
	}

	public static FileType getTypeFromExt(String ext) {
		for (FileType type : FileType.values()) {
			if (type.getExtensions().contains(ext)) {
				return type;
			}
		}
		return OTHER;
	}

}
